import java.math.BigInteger;
import java.util.Scanner;

/**
 *  十六进制转换十进制
 */
public class HexadecimaltoDecimal {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = new String();
        a = sc.nextLine();
        BigInteger x = new BigInteger(a,16);
        System.out.println(x.intValue());
    }

}
